{% extends 'shop/base.html' %}
{% block title %}
    个人中心
{% endblock %}
{% block style %}
    <script src="/static/shop/js/jquery.min.js"></script>
    <script src="/static/shop/js/bootstrap.js"></script>
    <link rel="stylesheet" href="/static/shop/css/bootstrap.css">
    <link rel="stylesheet" href="/static/shop/css/footer.css">
    <link rel="stylesheet" href="/static/shop/css/usercenterinfo.css">
    <link rel="stylesheet" href="/static/shop/css/search.css">
{% endblock %}
{% block lable %}
    <div class="search">
        <div class="row ">
            <!--左边图片和文字-->
            <div class="col-lg-5">
                <img src="/static/shop/images/logo.png" alt="..." class="img-rounded">
                <span>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;用户中心</span>
            </div>
            <!--右边表单-->
            <div class="col-lg-6 col-lg-offset-1 search_bar">
                 <form  method="post" action="/shop/seek/">
                    {% csrf_token %}
                    <div class="input-group">
                        <input type="text" class="form-control" placeholder="搜索商品" name="goods">
                        <span class="input-group-btn">
                    <button class="btn btn-success" style="padding: 6px 50px" type="submit" >搜索</button>
                </span>
                    </div>
                </form>
            </div>
        </div>
    </div>
{% endblock %}
{% block contenter %}
    <div class="main">
        <ul class="nav nav-tabs">
            <li role="presentation"><a href="#">个人信息</a></li>
            <li role="presentation"><a href="#">全部订单</a></li>
            <li role="presentation" class="active"><a href="#">收货地址</a></li>
        </ul>
        <br/>
        <div class="info">
            <!--基本信息-->
            <div id="userinfo">
                <div class="panel panel-default">
                    <div class="panel-heading col-lg-12">
                        <span class="col-lg-11">用户基本信息</span>
                        <span class="col-lg-1">
                            <a class="btn btn-default btn-xs" href="/shop/edituser/" role="button">&nbsp;&nbsp;修&nbsp;改&nbsp;&nbsp;</a>
                        </span>
                    </div>
                    <div class="panel-body">
                        <div>
                            用户名: {{ user.username }} <br/>
                            联系方式: {{ user.quserinfo.phone }} <br/>
                            联系地址: {{ user.quserinfo.address }}
                        </div>
                    </div>
                    <div class="panel-heading">最近浏览</div>
                    <div class="row">
                        {% for goods in recent_glance_list %}
                            <div class="col-md-3">
                                <a href="/shop/detail/{{ goods.id }}/" class="thumbnail">
                                    <img src="/static/{{ goods.g_picture }}" alt="..." width="200px" height="200px">
                                </a>
                                <div style="text-align: center">
                                    <h4><a href="detail.html">{{ goods.g_name }}</a></h4>
                                    <span class="prize" style="color: red">￥{{ goods.g_price }}</span>
                                    <span class="unit">{{ goods.g_price }}/{{ goods.g_unit }}</span>
                                </div>
                            </div>
                        {% endfor %}
                    </div>
                </div>
            </div>
            <!--所有订单-->
            <div id="allorders">
                <div class="panel panel-default ">
                    <div class="panel-heading col-lg-12">未支付</div>
                    <div class="panel-body">
                        <table class="table table-bordered table-hover">
                            {% for order in yet_order_list %}
                                {% for g in order.o_goods.all %}
                                    <tr align="center" valign="middle">
                                        <td>
                                            <img class="img-thumbnail" src="/static/{{ g.g_picture }}" width="60px"
                                                 alt="">
                                        </td>
                                        <td>{{ g.g_name }}</td>
                                        <td>{{ g.g_price }}元/{{ g.g_unit }}</td>
                                        <td>1</td>
                                    </tr>
                                {% endfor %}
                                <tr>
                                    <td colspan="4" align="right">订单号:{{ order.order_number }}<a class="btn"
                                                                                                 href="/shop/re_pay/{{ order.id }}/">去付款</a><a
                                            class="btn" href="/shop/delete_order/{{ order.id }}/">取消订单</a></td>
                                </tr>
                            {% endfor %}
                        </table>
                    </div>
                    <div class="panel-heading col-lg-12">已支付</div>
                    <div class="panel-body">
                        <table class="table table-bordered table-hover">
                            {% for order in done_order_list %}
                                {% for g in order.o_goods.all %}
                                    <tr align="center" valign="middle">
                                        <td>
                                            <img class="img-thumbnail" src="/static/{{ g.g_picture }}" width="60px"
                                                 alt="">
                                        </td>
                                        <td>{{ g.g_name }}</td>
                                        <td>{{ g.g_price }}元/{{ g.g_unit }}</td>
                                        <td>1</td>
                                    </tr>
                                {% endfor %}
                                <tr>
                                    <td colspan="4" align="right">订单号:{{ order.order_number }}<a class="btn"
                                                                                                 href="/shop/delete_order/{{ order.id }}/">删除订单</a>
                                    </td>
                                </tr>
                            {% endfor %}
                        </table>
                    </div>
                    <div align="center">
                        <nav aria-label="...">
                            <ul class="pagination">
                                <li class="disabled"><a href="#" aria-label="Previous"><span
                                        aria-hidden="true">&laquo;</span></a></li>
                                <li class="active"><a href="#">1 <span class="sr-only">(current)</span></a></li>
                                <li><a href="#">2</a></li>
                                <li><a href="#">3</a></li>
                                <li><a href="#">4</a></li>
                                <li><a href="#">5</a></li>
                                <li>
                                    <a href="#" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
            <!--收货地址-->
            <div id="address">
                <div class="panel panel-default ">
                    <div class="panel-heading col-lg-12">当前地址:</div>
                    <div class="panel-body">
                        <div class="col-lg-8">
                            {% for addr in address_list %}
                                <div class="radio">
                                    <label>
                                        <input type="radio" name="optionsRadios" id="optionsRadios1"
                                               value="{{ addr.id }}"
                                               checked>
                                        {{ addr.acc_addr }}
                                    </label>
                                    <a href="/shop/addr_manage/{{ addr.id }}/" class="btn btn-default">编辑</a>
                                </div>
                            {% endfor %}
                        </div>
                    </div>
                    <div class="panel-heading">添加地址</div>
                    <div class="panel-body">
                        <div class="row col-lg-8" style="margin-top: 10px">
                            <form class="form-horizontal" action="/shop/addr_edit/" method="post">
                                {% csrf_token %}
                                <div class="form-group">
                                    <label for="shoujianren" class="col-sm-2 control-label">收件人</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="shoujianren" placeholder="收件人"
                                               name="acc_name">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="xiangxiaddress" class="col-sm-2 control-label">详细地址</label>
                                    <div class="col-sm-10">
                                    <textarea class="form-control" placeholder="详细地址" id="xiangxiaddress"
                                              rows="3" name="acc_addr"></textarea>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="youbian" class="col-sm-2 control-label">邮编</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="youbian" placeholder="邮政编码"
                                               name="acc_post">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="youbian" class="col-sm-2 control-label">手机</label>
                                    <div class="col-sm-10">
                                        <input type="text" class="form-control" id="phone" placeholder="手机号"
                                               name="acc_phone">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label for="youbian" class="col-sm-2 control-label">设为默认地址</label>
                                    <div class="col-sm-10">
                                        <input type="checkbox" class="checkbox" name='is_default' value="1">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <button type="submit" class="btn btn-default col-lg-4 col-lg-offset-4">&nbsp;&nbsp;提&nbsp;交&nbsp;&nbsp;
                                    </button>
                                </div>
                            </form>
                        </div>
                    </div>

                </div>

            </div>
        </div>
    </div>
{% endblock %}
{% block script %}
    <script>
        $(function () {
            // 选项卡切换
            $("ul li").on("click", function () {

                //获取索引值
                var index = $(this).index();
                $(".info>div").eq(index).show().siblings().hide();
                console.log($(this)[0]);
                $(this).addClass('active');
                $(this).siblings().removeClass('active');

            });
        });
    </script>
{% endblock %}
